class LoginController < ApplicationController
  def login_form
    @error = flash[:error]
    reset_session
  end
  
  def login
    @user = User.find_by_login(params[:login])
    
    if @user && (@user.password == params[:password])
      session[:user_id] = @user.id
      redirect_to :controller => "articles", :action => "list"
    else
      flash[:error] = "로그인 ID나 비밀번호가 틀렸습니다.!"
      redirect_to :action => "login_form"
    end
  end
  
  def logout
    reset_session
    redirect_to :action => "login_form"
  end
end
